# file=[
#           ["F1_book_05448_chp_0038_reader_06708_1.wav","M1_book_11346_chp_0030_reader_00812_9.wav"],
#           ["F2_clean_fileid_9371.wav","M2_clean_fileid_11248.wav"],
#           ["M1_book_11346_chp_0030_reader_00812_9.wav","F1_book_05448_chp_0038_reader_06708_1.wav"],
#           ["M2_clean_fileid_11248.wav","F2_clean_fileid_9371.wav"],
#           ["F1_book_05448_chp_0038_reader_06708_1.wav","F2_clean_fileid_9371.wav","M2_clean_fileid_11248.wav"],
#           ["M1_book_11346_chp_0030_reader_00812_9.wav","M2_clean_fileid_11248.wav"],
          
          
#           ["F1_VCTK_unseen_p228_001_mic1.wav","M1_VCTK_p376_006_mic1.wav"],
#           ["F2_VCTK_unseen_p253_008_mic1.wav","M2_VCTK_unseen_p263_007_mic1.wav"],
#           ["M1_VCTK_p376_006_mic1.wav","F1_VCTK_unseen_p228_001_mic1.wav"],
#           ["M2_VCTK_unseen_p263_007_mic1.wav","F2_VCTK_unseen_p253_008_mic1.wav"],
#           ["F1_VCTK_unseen_p228_001_mic1.wav","F2_VCTK_unseen_p253_008_mic1.wav"],
#           ["M1_VCTK_p376_006_mic1.wav","M2_VCTK_unseen_p263_007_mic1.wav"]
#           ]

import os
import json

male_speaker=["p376","p263"]
female_speaker=["p228","p253"]
total=10

root_path="/opt/data/private/VC/VCTK/Dataset/VCTK-Corpus/wav48_silence_trimmed"
pair_dict=list()

for speaker_source in male_speaker:
    for speaker_target in female_speaker:
        
        source_speaker_dir=os.path.join(root_path,speaker_source)
        source_dir_wav_name=sorted(os.listdir(source_speaker_dir))
        
        target_speaker_dir=os.path.join(root_path,speaker_target)
        target_dir_wav_name=sorted(os.listdir(target_speaker_dir))
        
        # print(source_dir_wav_name[0])
        
        for index in range(total):
            source_wav_path=os.path.join(speaker_source,source_dir_wav_name[index*2])
            target_wav_path=os.path.join(speaker_target,target_dir_wav_name[index*2])
            # pair_dict=list()
            # pair_dict.append(source_dir_wav_name)
            # pair_dict.append(target_dir_wav_name)
            # print(pair_dict)
            # print([source_wav_path,target_wav_path])
            pair_dict.append([source_wav_path,target_wav_path])
            
for speaker_source in female_speaker:
    for speaker_target in male_speaker:
        
        source_speaker_dir=os.path.join(root_path,speaker_source)
        source_dir_wav_name=sorted(os.listdir(source_speaker_dir))
        
        target_speaker_dir=os.path.join(root_path,speaker_target)
        target_dir_wav_name=sorted(os.listdir(target_speaker_dir))
        
        # print(source_dir_wav_name[0])
        
        for index in range(total):
            source_wav_path=os.path.join(speaker_source,source_dir_wav_name[index*2])
            target_wav_path=os.path.join(speaker_target,target_dir_wav_name[index*2])
            # pair_dict=list()
            # pair_dict.append(source_dir_wav_name)
            # pair_dict.append(target_dir_wav_name)
            # print(pair_dict)
            # print([source_wav_path,target_wav_path])
            pair_dict.append([source_wav_path,target_wav_path])
print(pair_dict)

with open('json_test.txt','w+') as f:
    json.dump(pair_dict,f)